class Loading extends eui.Component implements  eui.UIComponent  {
    /**
     * 提示
     * msg为提示语
     * t为延迟 ms
    */
    private msg:string = "加载中...";
	private t:number = 0;
	private showTimeout;
	public constructor(t?:number,msg?:string) {
		super();
		this.visible = false;
        this.msg = msg;
		if(msg){
			this.msg = msg;
		}
		if(t){
			this.t = t;
		}
	}

	private loadImg:eui.Image;
	private loadGroup:eui.Group;

	protected childrenCreated():void
	{
		super.childrenCreated();
		if(this.t>0){
			this.showTimeout = setTimeout(()=>{
				this.init();
			},this.t)
		}else{
			this.init();
		}
	}

    private init(){
		this.visible = true;
        Utils.setStage(this);
		Utils.resetScale(this.loadGroup);

		egret.Tween.get(this.loadImg, { loop: true }).to({horizontalCenter:10,y:30},400,egret.Ease.backOut).call(()=>{
			this.loadImg.source = "loadimg1_png";
		}).to({horizontalCenter:0,y:20},400).call(()=>{
			this.loadImg.source = "loadimg2_png";
		});
    }

    //移除loading
    public removeLoading(){
        try{
            clearTimeout(this.showTimeout);
            egret.Tween.removeTweens(this.loadImg);
        	this.removeChildren();
			if(this.parent){
				this.parent.removeChild(this);
			}
        }catch(e){}
    }
}